package com.haoze.nurse.component;

import com.haoze.nurse.dao.NursePatientMapper;
import com.haoze.nurse.service.impl.NursePatientServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @Classname PatientComponentImpl
 * @Description TODO
 * @Date 2021/2/8 14:32
 * @Created by szj
 */
@Component
public class PatientComponentImpl implements PatientComponent{
    private static final Logger logger = LoggerFactory.getLogger(PatientComponentImpl.class);

    @Resource
    NursePatientMapper nursePatientMapper;
    /**
     * 组装血型
     * @param patient
     */
    @Override
    public <T> void componentBlood(Map<String, T> patient) {
        List<Map<String, String>> result = nursePatientMapper.queryBloodABOAndRH(patient.get("inpatNum").toString());
//        String reportResult = "";
        String reportResultRH = "";
        String reportResultAOB = "";
        for (Map<String, String> map : result) {
            if ("ABO-F".equals(map.get("LAB_REPORT_ITEM_CODE")) || (StringUtils.isNotBlank(map.get("labReportItemName")) && map.get("labReportItemName").startsWith("ABO血型"))) {
                reportResultAOB = map.get("REPORT_RESULT");
                continue;
            }
            if ("RH-F".equals(map.get("LAB_REPORT_ITEM_CODE")) || (StringUtils.isNotBlank(map.get("labReportItemName")) && map.get("labReportItemName").startsWith("RH血型"))) {
                reportResultRH = map.get("REPORT_RESULT");
                continue;
            }
        }
       /* if (!"".equals(reportResultAOB)) {
            reportResult = new StringBuilder(reportResultAOB)
                    .append("(")
                    .append(reportResultRH)
                    .append(")")
                    .toString();
        }*/
        patient.put("bloodTypeAOB", (T)reportResultAOB);//血型AOB
        patient.put("bloodTypeRH", (T)reportResultRH);//血型RH
//        patient.put("bloodType", (T)reportResult);//血型AOB(RH)
    }
}
